Keeping a Standard Coding Template

One old trick I had when learning to program was keeping a standard coding template. In it, I had a common list of import declarations so I would be covered for virtually all my needs. Then, use an IDE such as NetBeans, JBuilder, JCreator, or Eclipse that can autocomplete methods for you. For example, a beginner might want to copy and paste this template for basic console/command-line apps:

/*
  * basic template
  */
import java.io.*;
import java.util.*;
// add more imports here when desired

public class BasicProgram {
     public BasicProgram() {
     }

     public static void main(String[] args) {
        BasicProgram program = new BasicProgram();
        program.method1();
     }

     public void method1() {
        System.out.println("Hello, Universe!");
     }
}

Tip: The java.lang package is imported by default in all Java programs.

Related:

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.